﻿<%@ WebHandler Language="C#" Class="SizeHandler" %>

using System;
using System.Web;
using SeDuce.BLL;
using SeDuce.Model;

public class SizeHandler : IHttpHandler {

    Lazy_Yu<SizeBLL> lazySizeBLL = new Lazy_Yu<SizeBLL>(() => new SizeBLL());
    public SizeBLL LazySizeBLL
    {
        get { return this.lazySizeBLL.Value; }
    }
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        SizeData sizeData = context.Request.Form["sizedata"].ToString().FromJsonTo<SizeData>();

        JSONStatus status = new JSONStatus() { Status = "0" };
        if (sizeData.SizeList.Count > 0)
        {
            if (!this.LazySizeBLL.UpdateSizes(sizeData.SizeList))
            {
                status.Status = "1";
            }
        }

        context.Response.Write(status.ToJSON());
        context.Response.End();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}